/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.webaccess.retailws.Util;

import com.webaccess.retailws.Bean.BrandBean;
import com.webaccess.retailws.Delegate.BrandDelegate;
import org.apache.struts.upload.FormFile;

/**
 *
 * @author Owner
 */
public class BrandUtil {

    CommonUtil commUtil = null;
    BrandBean brandBeanObj = null;
    BrandDelegate brandDelegateObj = null;

    public BrandUtil() {
        commUtil = new CommonUtil();
    }

    public String uploadFile(FormFile brandLogo, String filePath) {
        return commUtil.uploadFile(brandLogo, filePath);
    }

    public String saveBrand(Long brandId, String brandName, String brandLogoName, String brandDesc, String brandTitle, Long brandStatusId) {
        brandDelegateObj = new BrandDelegate();
        String SUCCESS = "";
        try {
            brandBeanObj = new BrandBean();
            brandBeanObj.setBrandId(brandId);
            brandBeanObj.setBrandName(brandName);
            brandBeanObj.setBrandLogoName(brandLogoName);
            brandBeanObj.setBrandDesc(brandDesc);
            brandBeanObj.setBrandTitle(brandTitle);
            brandBeanObj.setBrandStatusId(brandStatusId);
            boolean isBrandSaved = brandDelegateObj.saveBrand(brandBeanObj);
            if (brandId == null) {
                if (isBrandSaved == false) {
                    SUCCESS = "savebrandfailure";
                } else {
                    SUCCESS = "brandsuccess";
                }
            } else {
                if (isBrandSaved == false) {
                    SUCCESS = "updatebrandfailure";
                } else {
                    SUCCESS = "brandsuccess";
                }
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            return SUCCESS;
        }
    }
}
